//富文本 插件
var WxParse = require('../wxParse/wxParse.js');

Page({
 
  data: {
    activeIndex: 0,
    content: '第1章' ,
    articsList : null 
  },
 
  onLoad: function (options) {
    var that = this;
    this.getMyArtics();

    WxParse.emojisInit('[]', "../wxParse/emojis/", {
      "00": "00.gif",
      "01": "01.gif",
      "02": "02.gif",
      "03": "03.gif",
      "04": "04.gif",
      "05": "05.gif",
      "06": "06.gif",
      "07": "07.gif",
      "08": "08.gif",
      "09": "09.gif",
      "09": "09.gif",
      "10": "10.gif",
      "11": "11.gif",
      "12": "12.gif",
      "13": "13.gif",
      "14": "14.gif",
      "15": "15.gif",
      "16": "16.gif",
      "17": "17.gif",
      "18": "18.gif",
      "19": "19.gif",
    });

    
  },

  changeArticInfoShow: function ( ) {
    var article = this.data.articsList[this.data.activeIndex].articTxt;
    WxParse.wxParse('article', 'html', article, this, 5);
  },

  
  changeTab: function (event) {

    this.setData({
      activeIndex: event.currentTarget.dataset.index,
      content: event.currentTarget.dataset.name 
      
    }) ;
  
    this. changeArticInfoShow();
  },


 


  getMyArtics: function () {
    wx.showLoading({
      title: 'loading',
    })
    const that = this;
    wx.request({
      url: 'https://www.aivin666.cn/AivinInfo/getAllArticInfoGson',
      data: { pageNum: 2 },
      header: {
        'Content-Type': 'application/json'
      },
      method: 'post',

      success: function (res) {
       
        that.setData({
         articsList: res.data
        });
        var article = that.data.articsList[that.data.activeIndex].articTxt;
        WxParse.wxParse('article', 'html', article, that, 5)
        wx.hideLoading();
       
      }
    })
  },


  
  onPullDownRefresh: function () {

  },
 
  onReachBottom: function () {

  },
 
  onShareAppMessage: function () {

  }
})